-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
docker-compose-logs: add page #18937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker-compose-logs: add page #18937
Conversation
Add page for docker-compose logs command to view output from containers.
|
The CI failure is due to Docker Hub service unavailability (503 error), not related to the PR changes. The checks should pass once Docker Hub services are restored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I noticed that the page uses the older docker-compose CLI. The newer one uses docker compose (without the hyphen).
Co-authored-by: Harshavardhan <[email protected]>
Co-authored-by: Harshavardhan <[email protected]>
Co-authored-by: Harshavardhan <[email protected]>
|
@TheRootDaemon thanks for pointing out this issue of newer version. |
|
Is the new version identical in its syntax? |
The hyphen is the only thing that changes. So no syntax changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what to use for a generic placeholder.
Whether to use {{N}} or {{line_count}} or just {{count}}.
But 100 won't generic, What do you think @anishk85 ?
pages/common/docker-compose-logs.md
Outdated
|
|
||
| - View only the last N lines of logs for each container: | ||
|
|
||
| `docker compose logs {{[-n|--tail]}} {{100}}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| `docker compose logs {{[-n|--tail]}} {{100}}` | |
| `docker compose logs {{[-n|--tail]}} {{line_count}}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All are valid. Depends on what you want to do.
Do you want to describe the purpose of said number with words? Use {{line_number}}
Want to demonstrate with an example what the argument should look like? Use {{2474627}}
Want to keep it super simple with a one-letter variable? Use {{n}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially used {{100}} as an example value to show a realistic usage(showing the last 100 lines), which is a common option in Docker and Unix commands (--tail 100, similar to tail -n 100).
Since I agree with you to use a generic placeholder it's better for new users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of now for new users I think we should use line_count only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want a generic placeholder like {{N}}.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use lowercase {{n}} for consistency.
Co-authored-by: Harshavardhan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested that these commands work?
yes for sure |
➜ ~/test cat compose.yaml
services:
web:
image: nginx:latest
container_name: demo_web
ports:
- "8080:80"
volumes:
- web_data:/usr/share/nginx/html
cache:
image: redis:latest
container_name: demo_cache
ports:
- "6379:6379"
volumes:
web_data:
➜ ~/test docker compose logs >> logs
➜ ~/test docker compose logs -t>> logs
➜ ~/test docker compose logs --timestamps>> logs
➜ ~/test docker compose logs -n 10
demo_cache | 1:M 24 Oct 2025 15:31:56.507 * <ReJSON> Exported RedisJSON_V2 API
demo_cache | 1:M 24 Oct 2025 15:31:56.507 * <ReJSON> Exported RedisJSON_V3 API
demo_cache | 1:M 24 Oct 2025 15:31:56.507 * <ReJSON> Exported RedisJSON_V4 API
demo_cache | 1:M 24 Oct 2025 15:31:56.507 * <ReJSON> Exported RedisJSON_V5 API
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 31
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 32
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 33
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 34
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 35
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 36
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 37
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 38
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 39
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 40
demo_cache | 1:M 24 Oct 2025 15:31:56.507 * <ReJSON> Enabled diskless replication
demo_cache | 1:M 24 Oct 2025 15:31:56.507 * <ReJSON> Initialized shared string cache, thread safe: false.
demo_cache | 1:M 24 Oct 2025 15:31:56.507 * Module 'ReJSON' loaded from /usr/local/lib/redis/modules//rejson.so
demo_cache | 1:M 24 Oct 2025 15:31:56.507 * <search> Acquired RedisJSON_V5 API
demo_cache | 1:M 24 Oct 2025 15:31:56.508 * Server initialized
demo_cache | 1:M 24 Oct 2025 15:31:56.508 * Ready to accept connections tcp
➜ ~/test docker compose logs --tail 10
demo_cache | 1:M 24 Oct 2025 15:31:56.507 * <ReJSON> Exported RedisJSON_V2 API
demo_cache | 1:M 24 Oct 2025 15:31:56.507 * <ReJSON> Exported RedisJSON_V3 API
demo_cache | 1:M 24 Oct 2025 15:31:56.507 * <ReJSON> Exported RedisJSON_V4 API
demo_cache | 1:M 24 Oct 2025 15:31:56.507 * <ReJSON> Exported RedisJSON_V5 API
demo_cache | 1:M 24 Oct 2025 15:31:56.507 * <ReJSON> Enabled diskless replication
demo_cache | 1:M 24 Oct 2025 15:31:56.507 * <ReJSON> Initialized shared string cache, thread safe: false.
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 31
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 32
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 33
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 34
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 35
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 36
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 37
demo_cache | 1:M 24 Oct 2025 15:31:56.507 * Module 'ReJSON' loaded from /usr/local/lib/redis/modules//rejson.so
demo_cache | 1:M 24 Oct 2025 15:31:56.507 * <search> Acquired RedisJSON_V5 API
demo_cache | 1:M 24 Oct 2025 15:31:56.508 * Server initialized
demo_cache | 1:M 24 Oct 2025 15:31:56.508 * Ready to accept connections tcp
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 38
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 39
demo_web | 2025/10/24 15:31:56 [notice] 1#1: start worker process 40
➜ ~/test docker compose logs web >> logs
➜ ~/test docker compose logs cache >> logsThe logs from the commands, if you need it... Pardon me if it is too messy. |
Great to see such amazing and helpful people exist in the community. 🙏 |
Add page for docker-compose logs command to view output from containers.
If you are a new contributor to the project, do not use AI to generate pages. We will close any PR with a suspicion of AI usage.
common,linux,osx,windows,sunos,android, etc.